$(function () {
    var url = "/except/indentcontroller/logisticinfo.action";
    var token = $("#token").val();
    if(isempty(token))
        token="null";
    var jsonstr = "{token:" + token + "}";
    var indentnum = $("#indentnum").val();
    $.ajax({
        url: url,
        type: 'post',
        dataType: "json",
        data: {
            json:jsonstr,
            indentnum:indentnum
        },
        async: false,
        success: function (data) {
            var code = data.code;
            var message = data.message;
            if (code == 20000) {
                $("#shopimg").attr("src", data.data.img);
                $("#state").html(data.data.statedesc);
                $("#ShipperName").html(data.data.ShipperName);
                $("#logisticsnum").html(data.data.logisticsnum);

                var traces = data.data.traces;
                var length = data.data.length;
                var logisticinfo = "";
                if(!isempty(traces) && length > 0) {
                    var i = 0;
                    $(traces).each(function () {
                        if(length == 1) {
                            logisticinfo += '<div class="itemlist already now">'+
                                '<div class="upline"></div>'+
                                '<div class="leftline"></div>'+
                                '<div class="point"></div>'+
                                '<p class="where">'+this.AcceptStation+'</p>'+
                                '<p class="time">'+this.AcceptTime+'</p>'+
                                '</div>';
                        } else {
                            if(i == 0) {
                                logisticinfo += '<div class="itemlist already now">'+
                                    '<div class="upline"></div>'+
                                    '<div class="leftline"></div>'+
                                    '<div class="point"></div>'+
                                    '<p class="where">'+this.AcceptStation+'</p>'+
                                    '<p class="time">'+this.AcceptTime+'</p>'+
                                    '</div>';
                            } else if (length == i + 1) {
                                logisticinfo += '<div class="itemlist begin">'+
                                    '<div class="upline"></div>'+
                                    '<div class="leftline"></div>'+
                                    '<div class="point"></div>'+
                                    '<p class="where">'+this.AcceptStation+'</p>'+
                                    '<p class="time">'+this.AcceptTime+'</p>'+
                                    '</div>';
                            } else {
                                logisticinfo += '<div class="itemlist">'+
                                    '<div class="upline"></div>'+
                                    '<div class="leftline"></div>'+
                                    '<div class="point"></div>'+
                                    '<p class="where">'+this.AcceptStation+'</p>'+
                                    '<p class="time">'+this.AcceptTime+'</p>'+
                                    '</div>';
                            }
                        }
                        i ++;

                    });
                }
                $("#logisticinfo").empty().append(logisticinfo);
                remove_advertising();
            } else if(code == 10001 || code == 10002){
                location.href = "/except/login.jsp";
            } else {
                $("#hintbg").show();
                $("#hint_message").html(message);
            }
        },
        error: function (data) {
            $("#hintbg").show();
            $("#hint_message").html("网络错误");
        }
    });
});